package vue;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import controleur.ControleBtnK0;

import modele.CKModel;

public class PanelK0 extends JPanel {

	
	static final long serialVersionUID = 12345;

	CKModel<String, String> _modele;
	VueEditeurCK _vue;
	
	private JLabel lblK0;
	private JTextArea txtK0;
	private JScrollPane scp;
	private JLabel lblErrorK0;
	private JButton btnValiderK0;
	
	
	public PanelK0(CKModel<String, String> modele, VueEditeurCK vue){

		this._modele = modele;
		this._vue = vue;
		
		this.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		
		
		lblK0 = new JLabel("Entrez un K0");
		lblK0.setPreferredSize(new Dimension(200,30));
		gbc.fill = GridBagConstraints.BOTH;
		gbc.anchor = GridBagConstraints.LINE_START;
		gbc.gridx = 0;
		gbc.gridy = 0;
		Insets i = new Insets(5, 5, 5, 5);
		gbc.insets = i;
		this.add(lblK0,gbc);
		
		txtK0 = new JTextArea();
		//txtK0.setPreferredSize(new Dimension(300, 100));
		txtK0.setLineWrap(true);
		scp = new JScrollPane(txtK0, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
		        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.gridx = 1;
		gbc.gridy = 0;
		this.add(scp,gbc);
		
		lblErrorK0 = new JLabel("");
		lblErrorK0.setPreferredSize(new Dimension(200,30));
		lblErrorK0.setForeground(Color.RED);
		gbc.anchor = GridBagConstraints.LINE_END;
		gbc.gridx = 2;
		gbc.gridy = 0;
		this.add(lblErrorK0, gbc);
		
		btnValiderK0 = new JButton("Valider");
		btnValiderK0.setPreferredSize(new Dimension(200,30));
		btnValiderK0.addActionListener(new ControleBtnK0(_modele, _vue));
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.gridx = 1;
		gbc.gridy = 1;
		this.add(btnValiderK0, gbc);
		
		
	}
	
	public String getTextK0(){
		return this.txtK0.getText();
	}
	
	
	public JButton getBtnValider(){
		return this.btnValiderK0;
	}
	


	/**
	 * @param lblErrorK0 the lblErrorK0 to set
	 */
	public void setLblErrorK0(String erreur) {
		this.lblErrorK0.setText(erreur);
	}


	/**
	 * @return the lblErrorK0
	 */
	public JLabel getLblErrorK0() {
		return lblErrorK0;
	}
	
}